package com.example.apkplugdemo;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;

import org.apkplug.app.FrameworkFactory;
import org.apkplug.app.FrameworkInstance;
import org.osgi.framework.BundleActivator;

import com.apkplug.appServiceManager;

import android.app.Application;
import android.util.DisplayMetrics;
import android.view.WindowManager;

public class ProxyApplication extends Application {
	private FrameworkInstance frame=null;
	
	public FrameworkInstance getFrame() {
		return frame;
	}

	public void onCreate() {   
		 super.onCreate(); 
		 try
	        {
	        	//启动框架
				//文档见 http://www.apkplug.com/javadoc/Maindoc1.4.6/
				//org.apkplug.app 
				//     接口 FrameworkInstance
				//com.apkplug.appServiceManager 为Service.jar包提供的插件托管服务启动BundleActivator
				List activators=new java.util.ArrayList<BundleActivator>();
	                       //将服务加入框架，框架将在启动时启动这些服务
				activators.add(new appServiceManager());
				frame=FrameworkFactory.getInstance().start(activators,this,new MyProperty(this.getApplicationContext()));
				
	        }
	        catch (Exception ex)
	        {
	            System.err.println("Could not create : " + ex);
	            //ex.printStackTrace();
	            int nPid = android.os.Process.myPid();
				android.os.Process.killProcess(nPid);
	        }
	}

}
